//
//  FCEmployeeTableViewCell.m
//  customerRelation_Example
//
//  Created by 陈文斌 on 2019/2/19.
//  Copyright © 2019 64912907. All rights reserved.
//

#import "FCEmployeeSelectTableViewCell.h"
#import "CustomerRelationHeader.h"

@interface FCEmployeeSelectTableViewCell ()

@end

@implementation FCEmployeeSelectTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        _selectedStatusImageView = [[UIImageView alloc] init];
        [self addSubview:_selectedStatusImageView];
        [_selectedStatusImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-24);
            make.centerY.mas_equalTo(0);
            make.width.and.height.mas_equalTo(24);
        }];
        _selectedStatusImageView.layer.cornerRadius = 12;
        if (self.isEnabled) {
            _selectedStatusImageView.image = customerRelationImageName(@"ic_unselected_circle");
        } else{
            _selectedStatusImageView.image = customerRelationImageName(@"ic_selected_circle_disable");
        }
        
        
        _avatarImageView = [[UIImageView alloc] init];
        [self addSubview:_avatarImageView];
        [_avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_offset(32);
            make.centerY.mas_equalTo(0);
            make.width.and.height.mas_equalTo(36);
        }];
        FCSETLRViewBorderRadius(_avatarImageView, 18);
        
        _employeeNameLabel = [[UILabel alloc] init];
        [self addSubview:_employeeNameLabel];
        _employeeNameLabel.font = font15;
        _employeeNameLabel.textColor = FCTxtColor;
        _employeeNameLabel.numberOfLines = 1;
        [_employeeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_avatarImageView.mas_right).mas_offset(10);
            make.top.equalTo(_avatarImageView.mas_top).mas_offset(-3);
            make.right.mas_equalTo(16);
            make.height.mas_equalTo(21);
        }];
        _employeeDetailLabel = [[UILabel alloc] init];
        [self addSubview:_employeeDetailLabel];
        _employeeDetailLabel.font = font12;
        _employeeDetailLabel.textColor = FCGrayTxtPlaceColor;
        _employeeDetailLabel.numberOfLines = 1;
        [_employeeDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_avatarImageView.mas_right).mas_offset(10);
            make.bottom.equalTo(_avatarImageView.mas_bottom).mas_offset(3);
            make.right.mas_equalTo(16);
            make.height.mas_equalTo(17);
        }];
        UIView *lineView = [UIView new];
        [self addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_avatarImageView.mas_left).mas_equalTo(0);
            make.bottom.and.right.mas_equalTo(0);
            make.height.mas_equalTo(0.5);
        }];
        lineView.backgroundColor = FCLineColor;
    }
    return self;
}

- (void)changeEnabledWithEnabled:(Boolean)enabled{
    if (self.isEnabled) {
        _selectedStatusImageView.image = customerRelationImageName(@"ic_unselected_circle");
    } else{
        _selectedStatusImageView.image = customerRelationImageName(@"ic_selected_circle_disable");
    }
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.avatarImageView.layer.cornerRadius = self.avatarImageView.width/2;
}

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
